package cn.butcher.controller;

import cn.butcher.service.TeacherService;
import cn.butcher.vo.StudentLeaveMsg;
import com.tencentcloudapi.cdn.v20180606.models.Https;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class TeacherController {

    @Autowired
    TeacherService service;

    @RequestMapping("/teacher/approve")
    public String getList(HttpSession session, Model model) {
        List<StudentLeaveMsg> list = service.getList(Integer.parseInt((String) session.getAttribute("id")));
        model.addAttribute("list", list);
        return "page/teacher-approve";
    }

    @RequestMapping("/teacher/approve/{leId}/{status}")
    @ResponseBody
    public String changeStatus(@PathVariable("leId") int leId, @PathVariable("status") char status, String mark) {
        service.changeStatus(leId, status, mark);
        return "";
    }

    @RequestMapping("/counselor/approve")
    public String getList2(HttpSession session, Model model) {
        List<StudentLeaveMsg> list = service.getList2(Integer.parseInt((String) session.getAttribute("id")));
        model.addAttribute("list", list);
        return "page/counselor-approve";
    }
}
